//
//  QMoneyCell.m
//  QoilPublic
//
//  Created by 杨凯 on 16/7/4.
//  Copyright © 2016年 杨凯. All rights reserved.
//

#import "QMoneyCell.h"

@interface QMoneyCell()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet UILabel *moneyLabel;

@property (weak, nonatomic) IBOutlet UILabel *subLabel;

@property (weak, nonatomic) IBOutlet UIButton *cMoneyButton;

@end
@implementation QMoneyCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [_cMoneyButton blueStyle];
    _cMoneyButton.layer.cornerRadius = 5;
    _cMoneyButton.layer.masksToBounds = YES;
    if([QUserInfo sharedInfo].loginModel){
        self.subLabel.hidden = YES;
        self.cMoneyButton.hidden = NO;
    }else{
        self.subLabel.hidden = NO;
        self.cMoneyButton.hidden = YES;
    }
}


- (void)setLoginModel:(QLoginModel *)loginModel{

    _loginModel = loginModel;
    if(_loginModel){
        self.moneyLabel.hidden = NO;
        if(_loginModel.balance.length > 0){
            self.moneyLabel.text = [NSString stringWithFormat:@"￥%@",_loginModel.balance];
        }else{
            self.moneyLabel.text = [NSString stringWithFormat:@"￥0"];
        }
        self.cMoneyButton.hidden = NO;
        self.subLabel.hidden = YES;
    }else if([QUserInfo sharedInfo].loginModel && !_loginModel){
        self.moneyLabel.hidden = NO;
        self.moneyLabel.text = [QUserInfo sharedInfo].loginModel.balance;
        self.cMoneyButton.hidden = NO;
        self.subLabel.hidden = YES;
    }else if(![QUserInfo sharedInfo].loginModel){
        self.cMoneyButton.hidden = YES;
        self.moneyLabel.hidden = YES;
        self.subLabel.hidden = NO;
        self.subLabel.text = @"登录后可见";
    }
}

- (IBAction)cMoneyButtonAction:(id)sender {
    
    if(self.block){
        self.block();
    }
}

@end
